package redis

import (
	"wzgames/pkg/common/component"
)

type Component struct {
	component.DefaultComponent
}

func ID() string {
	return "s-redis"
}

func (redisc *Component) ID() string {
	return ID()
}

func (redisc *Component) Create(instConfig *component.ComponentConfig) (interface{}, error) {
	return NewRedisClient(instConfig.Name, instConfig.Config)
}

func (redisc *Component) Update(inst interface{}, instConfig *component.ComponentConfig) (interface{}, error) {
	r := inst.(*RedisClient)
	newInst, err := r.UpdateConfig(instConfig.Name, instConfig.Config)
	return newInst, err
}

func (redisc *Component) Destroy(inst interface{}) error {
	r := inst.(*RedisClient)
	return r.Destroy()
}
